package com.user.Service.Impl;

import com.common.util.Md5Util;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.user.Mapper.UserMapper;
import com.user.Pojo.User;
import com.user.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl  implements UserService {

    @Autowired
    private UserMapper userMapper;


    @Override
    public void AddUser(User user) {
        //加密
        String md5String = Md5Util.getMD5String(user.getPassword());
        user.setPassword(md5String);
        user.setRoleName("员工");
        userMapper.AddUser(user);
    }

    @Override
    public User UserIFNull(String userName) {
        return userMapper.UserIFNull(userName);
    }

    @Override
    public PageInfo<User> GetUser(Integer pageNum, Integer pageSize, String userName) {
        PageHelper.startPage(pageNum,pageSize);
        List<User> userList=userMapper.GetUser(userName);
        PageInfo<User> pageInfo=new PageInfo<>(userList);
        return pageInfo;
    }

    @Override
    public void UserDelete(Integer id) {
        userMapper.UserDelete(id);
    }

}
